package com.practice.bootdemo.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * description: 从配置文件author.yml中读取数据
 * create date: 2018/7/10 11:48
 */

@Component
@PropertySource(value = "classpath:author.yml" ,ignoreResourceNotFound = true)
@ConfigurationProperties(prefix = "author")
public class DataObjBindConfig {

    // 属性注入不能使用@Data 注解，因为是预编译前注入属性，此时@Data没有加载
    private String name;
    private int age;
    private List<String> habby;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public List<String> getHabby() {
        return habby;
    }

    public void setHabby(List<String> habby) {
        this.habby = habby;
    }
}
